<template>
    <view class="mask3 alpha0_100" v-if="innerShow">
        <view
            class="div_box big_normal"
            style="--div_box_width: 78%; --div_box_height: 680rpx; background: -webkit-linear-gradient(top, rgba(250, 74, 45, 0.2), #fff 15%); background-color: #fff"
        >
            <view class="S18 h2">用户隐私保护</view>
            <view class="S15">
                <view>当您使用本平台时即表示已理解并同意该条款内容，将对您产生法律约束力；如您拒绝，将无法正常使用</view>
                <view>
                    阅读并同意
                    <text @tap="openPrivacyContract" class="a">《用户隐私保护指引》</text>
                </view>
            </view>
            <button @tap="handleDisagree" class="btn5 dis" type="default">不同意并退出</button>
            <button @agreeprivacyauthorization="handleAgree" class="btn5 agree" openType="agreePrivacyAuthorization" type="default">同意并继续</button>
        </view>
    </view>
</template>

<script>
export default {
    data() {
        return {
            title: '用户隐私保护提示',
            desc1: '感谢您使用本平台，您使用本平台前应当阅井同意',
            urlTitle: '《用户隐私保护指引》',
            desc2: '当您点击同意并开始时用产品服务时，即表示你已理解并同息该条款内容，该条款将对您产生法律约束力。如您拒绝，将无法进入使用。',
            innerShow: false,
            height: 0
        };
    },
    mounted() {
        // 处理小程序 attached 生命周期
        this.attached();
    },
    methods: {
        attached: function () {
            var that = this;
            if (uni.getPrivacySetting) {
                uni.getPrivacySetting({
                    success: function (e) {
                        if (e.needAuthorization) {
                            that.popUp();
                        } else {
                            that.$emit('agree');
                        }
                    },

                    fail: function () {},
                    complete: function () {}
                });
            } else {
                this.$emit('agree');
            }
        },

        handleDisagree: function (t) {
            this.$emit('disagree');
            this.disPopUp();
        },

        handleAgree: function (t) {
            this.$emit('agree');
            this.disPopUp();
        },

        popUp: function () {
            this.setData({
                innerShow: true
            });
        },

        disPopUp: function () {
            this.setData({
                innerShow: false
            });
        },

        openPrivacyContract: function () {
            uni.openPrivacyContract({
                success: function (t) {
                    console.log('openPrivacyContract success');
                },
                fail: function (t) {
                    console.error('openPrivacyContract fail', t);
                }
            });
        }
    },
    created: function () {}
};
</script>
<style>
@import 'privacyPopup.css';
</style>
